#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<climits>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
LL a[N];
LL n, m;
int find(int x)
{
	LL left = 0, right = m + 1;
	while (left < right)
	{
		LL mid = (left + right) / 2;
		if (a[mid] < x) left = mid + 1;
		else right = mid;
	}
	return left;
}
int main()
{
	cin >> m >> n;
	for (int i = 1; i <= m; i++)cin >> a[i];
	LL ret = 0;
	sort(a + 1, a + m + 1);
	a[0] = INT_MIN; a[m + 1] = INT_MAX;
	while (n--)
	{
		LL x; cin >> x;
		LL pos = find(x);
		ret += min(abs(x - a[pos]), abs(x - a[pos - 1]));
	}
	cout << ret << endl;
	return 0;
}